package org.tong.controller;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.tong.service.ServiceThree;
import org.tong.service.ServiceTwo;

import java.util.Date;

@RestController
public class IndexController {

    private static final Logger log = LoggerFactory.getLogger(IndexController.class);

    @Autowired
    private ServiceTwo serviceTwo;

    @Autowired
    private ServiceThree serviceThree;

    @RequestMapping("/")
    public String index() {
        log.info("visit /");
        return msg();
    }

    @RequestMapping("/service")
    public String serviceTwo() {
        log.info("visit /service");
        return serviceTwo.index();
    }

    @RequestMapping("/series")
    public String series() {
        log.info("visit /series");
        return msg() + "->" + serviceTwo.series();
    }

    @RequestMapping("/parallel")
    public String parallel() {
        log.info("visit /parallel");
        return msg() + "->" + serviceTwo.index() + "-p->" + serviceThree.index();
    }

    private final String msg() {
        return "Welcome to ServiceOne" + new Date().toString();
    }
}
